import cv2
import numpy as np

img1 = cv2.imread("./img/O.png")
img2 = cv2.imread("./img/X.png")

# print(img1.shape)
# print(img2.shape)

# 提取O图像的三通道
# h1,w1,d1 = img1.shape
# tmp_img = img1.copy()
# tmp_img[:,:,0] = np.zeros((h1,w1))
# tmp_img[:,:,1] = img1[:,:,1]
# tmp_img[:,:,2] = np.zeros((h1,w1))

# 提取X图像的三通道
# h2,w2,d2 = img2.shape
# tmp_img = img2.copy()
# tmp_img[:,:,0] = np.zeros((h2,w2))
# tmp_img[:,:,1] = np.zeros((h2,w2))
# tmp_img[:,:,2] = img2[:,:,2]

# 融合图像
dic_img = img1.copy()
dic_img[:,:,0] = cv2.bitwise_and(img1[:,:,0],img2[:,:,0])
dic_img[:,:,1] = cv2.bitwise_and(img1[:,:,1],img2[:,:,1])
dic_img[:,:,2] = cv2.bitwise_and(img1[:,:,2],img2[:,:,2])

cv2.imshow("tmp",dic_img)
cv2.waitKey(0)